export default class AniStore {
	constructor() {
	}
	proxyStore(obj) {
		const that = this
		return new Proxy(obj,{
			get(target,property,receiver){
				console.log('获取了',target[property],receiver)
				return target[property]
			},
			set(target, p, value, receiver) {
				if(typeof value=='object'){
					for(let item in value){
						if(typeof  value[item]=='object'){
							value[item]=that.proxyStore(value[item])
						}
					}
					target[p]=that.proxyStore(value)
				}else{
					target[p]=value
				}
				that.triggerStore(p,value,target[p])
				target[p]=value
				return true
			}
		})
	}

	createProxy(obj){
		for(let item in obj){
			if(typeof  obj[item]=='object'){
				obj[item]=this.proxyStore(obj[item])
			}
		}
		return this.proxyStore(obj)
	}
	setStore(obj){
		console.log('触发了setStore')
	}
	create(obj){
		this.store=this.createProxy(obj)
		return this.store
	}
	triggerStore(key,newVal,oldVal){
		console.log('触发了修改',key,newVal,oldVal)
	}
}
